package com.zmn.oms.services.impl.member;

import com.zmn.oms.model.entity.member.OrderMember;
import com.zmn.oms.persistence.interfaces.member.OrderMemberDao;
import com.zmn.oms.services.interfaces.member.OrderMemberService;
import io.shardingsphere.api.HintManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类描述：会员订单扩展数据
 *
 * @author lujia
 * @date 2018/11/28 11:15
 */
@Service
public class OrderMemberServiceImpl implements OrderMemberService {

    @Autowired
    OrderMemberDao orderMemberDao;

    @Override
    public OrderMember findMemberByKey(Long key) {
        return orderMemberDao.findMemberByKey(key);
    }

    @Override
    public OrderMember findMemberByKeySrcMaster(Long key) {
        try (HintManager hintManager = HintManager.getInstance()) {
            hintManager.setMasterRouteOnly();
            return orderMemberDao.findMemberByKey(key);
        }
    }

    public List<OrderMember> listEsOrderMemberByOrderIdList(List<Long> orderIdList) {
        try (HintManager hintManager = HintManager.getInstance()) {
            hintManager.setMasterRouteOnly();
            return orderMemberDao.listEsOrderMemberByOrderIdList(orderIdList);
        }
    }

    @Override
    public int insertOrderMember(OrderMember orderMember) {
        return orderMemberDao.insert(orderMember);
    }

    @Override
    public int updatePlatReview(OrderMember orderMember) {
        return orderMemberDao.updatePlatReview(orderMember);
    }

    @Override
    public int updateMasterReview(OrderMember orderMember) {
        return orderMemberDao.updateMasterReview(orderMember);
    }

    @Override
    public int updateEquityType(OrderMember orderMember) {
        return orderMemberDao.updateEquityType(orderMember);
    }
}
